import QtQuick 1.0
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"


FocusScope {
  height : 700
  width : 1024
  focus:true
  DirectPlayer {
    id:moviePlayer
     onAllFinished : whenPlayerFinished();
  }
  TrailerPlayer{
    id:trailerPlayer
    onAllFinished : whenPlayerFinished();
  }
  
  HListMovie {
    id : mSelector
    height : parent.height
    width : parent.width
    anchors.left : parent.left
    focus:true
    
  }
  QmlSetting{
    id:setting
    appName:'allocine'
  }
  Connections {
      target: mSelector.detailQml
      onAction : {
	//console.log('ask for '+type + ' with' + mSelector.detailQml.currentObj.title);
	if(type=='trailer'){
	  trailerPlayer.playYTUrl(mSelector.detailQml.currentObj.trailerUrlYT);
	  return;
	}else if (type=='play'){
	  moviePlayer.url = setting.value('magikPrefix')+mSelector.detailQml.currentObj.url;
	  moviePlayer.nom = setting.value('homeVideo')+mSelector.detailQml.currentObj.title+'.avi';
	  moviePlayer.playMedia();
	  return;
	}
      }
  }
  
  function whenPlayerFinished(){
    console.log('player finished');
  }
  function killPlayers(){
    moviePlayer.kill();
    trailerPlayer.kill();
  }
  //moviePlayer.finished.connect : whenPlayerFinished;
  //trailerPlayer.finished.connect : whenPlayerFinished;
  
}